package com.atguigu.gmall.item.api;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.item.service.SkuInfoDetailService;
import com.atguigu.gmall.item.vo.SkuInfoDetailVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/api/inner/item")
public class SkuInfoDetailApiController {

    @Autowired
    private SkuInfoDetailService skuInfoDetailService ;

    @GetMapping(value = "/getSkuInfoDetail/{skuId}")
    public Result<SkuInfoDetailVo> findBySkuId(@PathVariable(value = "skuId") Long skuId) {
        SkuInfoDetailVo skuInfoDetailVo = skuInfoDetailService.findBySkuId(skuId) ;
        skuInfoDetailService.updateHotScore(skuId) ;        // 操作Redis更新商品的热点分
        return Result.build(skuInfoDetailVo , ResultCodeEnum.SUCCESS) ;
    }

}
